package com.bookshop.ui;

import java.awt.Dimension;
import java.awt.Toolkit;

import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

import com.bookshop.ui.component.BasePagePanel;
import com.bookshop.ui.login.LoginPage;

public class MainFrame extends JFrame{
	private PageJumper mJumper;
	
	public MainFrame() {
		init();
	}
	
	private void init(){
		
		JPanel panel = new BasePagePanel(null);
		setContentPane(panel);
		pack();
		
		mJumper = new PageJumper(panel);
		mJumper.loadPage(new LoginPage(mJumper));
		
		int windowWidth = getWidth(); 
		int windowHeight = getHeight(); 
		Toolkit kit = Toolkit.getDefaultToolkit(); 
		Dimension screenSize = kit.getScreenSize(); 
		int screenWidth = screenSize.width; 
		int screenHeight = screenSize.height; 
		setLocation(screenWidth/2 - windowWidth/2, screenHeight/2 - windowHeight/2);
		
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setVisible(true);
	}
	
	public void showMessage(String pMessage) {
		JOptionPane.showMessageDialog(this,pMessage);
	}
}
